<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <div id="app">
        <ul>
            <li v-for="(item,index) in list" :key="index">
                <span>{{item}}</span>
        </ul>

    </div>
    <script>
        const { createApp } = Vue
        createApp({
            data() {
                return {
                    list: [],
                }
            },
            methods: {
                async getCity() {
                    try {
                        const provinceweather1 = await axios({ url: 'http://hmajax.itheima.net/api/city', params: { pname: '江西省' } })
                        const provinceweather2 = await axios({ url: 'http://hmajax.itheima.net/api/city', params: { pname: '河南省' } })
                        const provinceweather3 = await axios({ url: 'http://hmajax.itheima.net/api/city', params: { pname: '四川省' } })
                        const provinceweather4 = await axios({ url: 'http://hmajax.itheima.net/api/city', params: { pname: '广东省' } })
                        const p = Promise.all([provinceweather1, provinceweather2, provinceweather3, provinceweather4])
                        p.then(res => {
                            this.list.push(
                                res[0].data.list[0], res[1].data.list[0], res[2].data.list[0], res[3].data.list[0]
                            )
                            console.log(this.list)
                        })
                    } catch (error) {
                        console.log(error)
                    }

                }
            },
            created() {
                this.getCity()
            },
            mounted() {
                // 可以在这里再次调用 getCity 方法，如果需要的话
                // this.getCity()
            }
        }).mount('#app')
    </script>
</body>

</html>